home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / CDTV / cdtvtools-11 / keeper / packcmap.asm < prev    next >
Encoding:
Assembly Source File  |  1991-06-24  |  1.4 KB  |  58 lines

  1. *****************************************************************************
  2. *
  3. *    packcmap.asm -- written by Ray Lambert for Theta Systems, Inc.
  4. *
  5. *    Copyright 1991 Commodore Business Machines, Inc.
  6. *
  7. *****************************************************************************
  8.  
  9.         INCLUDE        "keeper.i"
  10.  
  11. *****************************************************************************
  12. *
  13. * Synopsis:
  14. *    void PackCMAP(UBYTE *src, UWORD *cmap, ULONG colors)
  15. *
  16. * Parameters:
  17. *    src    : pointer to source data in RGB bytes
  18. *    cmap    : pointer to detination color map
  19. *    colors    : number of colors to pack
  20. *
  21. * Returns:    (in D0:)
  22. *    none
  23. *
  24. * Description:
  25. *     This routine takes RGB bytes from 'src' and packs them into 'cmap'
  26. *    nybbles.  'colors' indicates the number of cmap entries to be 
  27. *    packed -- 'src' is expected to contain 'colors' * 3 bytes.
  28. *
  29. *****************************************************************************
  30.  
  31.         FUNCTION    _PackCMAP,0
  32.         ARGUMENTS
  33.         ARG        _APTR,src
  34.         ARG        _APTR,cmap
  35.         ARG        _ULONG,colors
  36.         push.l        d2
  37.  
  38.         move.l        colors(a5),d0
  39.         move.l        src(a5),a0
  40.         move.l        cmap(a5),a1
  41.         dec.l        d0        ; correct for dbra
  42. 1$
  43.         move.b        (a0)+,d1    ; d1: xxRx
  44.         lsl.w        #4,d1        ; d1: xRx0
  45.         move.b        (a0)+,d1    ; d1: xRGx
  46.         and.w        #$0ff0,d1    ; d1: 0RG0
  47.         move.b        (a0)+,d2    ; d2: xxBx
  48.         lsr.b        #4,d2        ; d2: xx0B
  49.         or.b        d2,d1        ; d1: 0RGB
  50.         move.w        d1,(a1)+
  51.         dbra        d0,1$
  52.  
  53.         pull.l        d2
  54.         RETURN        _PackCMAP
  55.  
  56.  
  57.         END
  58.